﻿using oceanho.webapi.factory.httpCore;
using oceanho.webapi.factory.httpCore.Binder;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace oceanho.webapi.factory.httpAttr
{
    /// <summary>
    /// 定义一个自定义绑定参数标记类（ParamBinderAttribute），用于解决对义务方法的参数自定义绑定控制
    /// </summary>
    [AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)]
    public class ParamBinderAttribute : Attribute
    {
        /// <summary>
        /// 自定义绑定参数标记类（ParamBinderAttribute），用于解决对义务方法的参数自定义绑定控制
        /// </summary>
        /// <param name="binderType">使用typof()指定binder的Type</param>
        public ParamBinderAttribute(Type binderType)
        {
            if (binderType == null)
                throw new APIFW_ArgumentNullException("binderType不能为空");
            Binder = (IBinder)Activator.CreateInstance(binderType);
            if (Binder == null)
                throw new APIFW_ArgumentNullException("binderType必须是一个实现IBinder接口的类");
        }
        /// <summary>
        /// 获取一个值，该值表示：实现了IBinder接口的任意类
        /// </summary>
        public IBinder Binder { get; private set; }
    }
}
